<template>
  <div id="main-app">
    <h2>主应用框架</h2>
    <router-link to="/">加载主应用</router-link>
    <br />
    <router-link to="/p2/#/tree">加载应用P2</router-link>
    <br />
    <router-link to="/workbench/p2">加载应用workbench-p2</router-link>
    <router-view />
  </div>
</template>
<script>
import { start } from 'qiankun'
export default {
  beforeCreate() {
    start({
      excludeAssetFilter: (url) => {
        return url.indexOf('api.map.baidu.com') !== -1
      },
      prefetch: false,
      async fetch(url, ...args) {
        console.log('...args', ...args)
        const options = { ...args }
        if (/^\/[^/]+\/$/.test(url)) {
          // html文件设置无缓存请求头
          options.cache = 'no-cache'
        }
        return window.fetch(url, options)
      },
    })
  },
}
</script>

<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}
#main-app {
  background-color: #ffffff;
  height: 600px;
}

#microapp {
  border: 2px solid rgb(170, 168, 165);
  margin: 24px 66px;
  min-height: 300px;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
